package core;

public class Player extends Actor {
	public Player() {
		super();
		this.setVisible(true);
	}

	public Player(Room room) {
		this();
		this.setPos(room.getEntrance().getPos());
		room.addElement(this);
	}

	public Player(int pos, int hp, int maxHp) {
		super(pos, hp, maxHp);
		this.setVisible(true);
	}

	@Override
	public boolean usePotion(Potion p, Room room) {
		return intUsePotion(p, room);
	}

	@Override
	public String toString() {
		return "Player []" + super.toString();
	}

	private boolean intUsePotion(Potion p, Room room) {
		if (this.getPos() == p.getPos()) {
			this.setHp(this.getHp() + p.getPotency());
			if (this.getHp() > this.getMaxHp())
				this.setHp(this.getMaxHp());
			room.removeElement(p);
			return true;
		}
		return false;
	}

}
